home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / sco / scripts / kshfuncs / history < prev    next >
Encoding:
Text File  |  1997-08-26  |  756 b   |  26 lines

  1. # @(#) history.ksh
  2. # 1990 john h. dubois iii
  3. # 96/01/17 added 'history 0'
  4.  
  5. # history lists the last $LINES-5, or last 20 commands
  6. # history 0 lists all history
  7. # history n [ m ] lists command n or commands n through m
  8. # history -n [ -m ] lists the n or n through m most recent commands
  9. # history n -m and history -n m are illegal
  10. # n and m can be history numbers or command prefixes;
  11. # -n and -m must be numbers
  12. # history must be unaliased to use this
  13. function history {
  14.     if [ $# -eq 1 -a "$1" = 0 ]; then
  15.     fc -lr $((-HISTSIZE+1)) -1
  16.     else
  17.     case "$1" in
  18.     "") fc -l -1 -$((${LINES:-25}-5)); return;;
  19.     -[0-9]*) fc -lr $2 $1 -1;;
  20.     [0-9]*) h=`fc -l -1`; h=${h%%    *}; 
  21.         fc -lr -$(( $h-$1+1 )) -$(( $h-${2:-$1}+1 ));;
  22.     *) fc -lr $1 ${2:-$1}
  23.     esac
  24.     fi
  25. }
  26.